package com.bean.vo;

import com.bean.entity.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * 学生信息表
 */

public class StudentInfoVo implements Serializable {

    private Long id;
    private String  studentName;
    private Long classesId;
    private Integer gender;
    //出生地
    private String  bornplace;
    //籍贯
    private String  nativePlace;
    //民族
    private String  nation;
    //国籍
    private String  country;
    //政治面貌
    private String  political;
    //证件id
    private Integer  certificateId;
    //证件号码
    private String  cettificateNum;
    //证件有效期
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date certificateTime;
    private Integer age;
    private String  address;
    //血型
    private String  bloodtype;
    private String  fatherName;
    private String  motherName;
    private String  phone;
    private String  emergentPhone;
    //宿舍id
    private Integer  dormitoryId;
    //班主任id
    private Integer  teacherId;
    private Integer  roleId;
    private String  password;
    private String  dreamSchool;
    //是否独生子女
    private Integer  isPre;
    //是否受过学前教育
    private Integer  isOnly;
    //是否留守儿童
    private Integer  isLeftOver;
    //是否随迁子女
    private Integer  isMigrant;
    //是否进城务工随迁
    private Integer  isMigrantWorker;
    //是否是孤儿
    private Integer  isOrphan;
    //是否单亲
    private Integer  isSingleParent;
    //是否烈士或优抚子女
    private Integer  isMartyr;
    //是否残疾人
    private Integer  isDisabled;
    //是否政府购买学位
    private Integer  isAssinDegree;
    //是否需要申请资助
    private Integer  isSupport;
    //是否享受一补
    private Integer  isSubsidy;

    private Classes classes;
    private String genderName;
    private Certificate certificate;
    private Dormitory dormitory;
    private Teachers teachers;
    private Role role;

    //以下讲是否转化成字符串
    private String isPreName;
    private String isOnlyName;
    private String isLeftOverName;
    private String isMigrantName;
    private String isMigrantWorkerName;
    private String isOrphanName;
    private String isSingleParentName;
    private String isMartyrName;
    private String isDisabledName;
    private String isAssinDegreeName;
    private String isSupportName;
    private String isSubsidyName;

    @Override
    public String toString() {
        return "StudentInfoVo{" +
                "id=" + id +
                ", studentName='" + studentName + '\'' +
                ", classesId=" + classesId +
                ", gender=" + gender +
                ", bornplace='" + bornplace + '\'' +
                ", nativePlace='" + nativePlace + '\'' +
                ", nation='" + nation + '\'' +
                ", country='" + country + '\'' +
                ", political='" + political + '\'' +
                ", certificateId=" + certificateId +
                ", cettificateNum='" + cettificateNum + '\'' +
                ", certificateTime=" + certificateTime +
                ", age=" + age +
                ", address='" + address + '\'' +
                ", bloodtype='" + bloodtype + '\'' +
                ", fatherName='" + fatherName + '\'' +
                ", motherName='" + motherName + '\'' +
                ", phone='" + phone + '\'' +
                ", emergentPhone='" + emergentPhone + '\'' +
                ", dormitoryId=" + dormitoryId +
                ", teacherId=" + teacherId +
                ", roleId=" + roleId +
                ", password='" + password + '\'' +
                ", dreamSchool='" + dreamSchool + '\'' +
                ", isPre=" + isPre +
                ", isOnly=" + isOnly +
                ", isLeftOver=" + isLeftOver +
                ", isMigrant=" + isMigrant +
                ", isMigrantWorker=" + isMigrantWorker +
                ", isOrphan=" + isOrphan +
                ", isSingleParent=" + isSingleParent +
                ", isMartyr=" + isMartyr +
                ", isDisabled=" + isDisabled +
                ", isAssinDegree=" + isAssinDegree +
                ", isSupport=" + isSupport +
                ", isSubsidy=" + isSubsidy +
                ", classes=" + classes +
                ", genderName='" + genderName + '\'' +
                ", certificate=" + certificate +
                ", dormitory=" + dormitory +
                ", teachers=" + teachers +
                ", role=" + role +
                ", isPreName='" + isPreName + '\'' +
                ", isOnlyName='" + isOnlyName + '\'' +
                ", isLeftOverName='" + isLeftOverName + '\'' +
                ", isMigrantName='" + isMigrantName + '\'' +
                ", isMigrantWorkerName='" + isMigrantWorkerName + '\'' +
                ", isOrphanName='" + isOrphanName + '\'' +
                ", isSingleParentName='" + isSingleParentName + '\'' +
                ", isMartyrName='" + isMartyrName + '\'' +
                ", isDisabledName='" + isDisabledName + '\'' +
                ", isAssinDegreeName='" + isAssinDegreeName + '\'' +
                ", isSupportName='" + isSupportName + '\'' +
                ", isSubsidyName='" + isSubsidyName + '\'' +
                '}';
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    public Long getClassesId() {
        return classesId;
    }

    public void setClassesId(Long classesId) {
        this.classesId = classesId;
    }

    public Integer getGender() {
        return gender;
    }

    public void setGender(Integer gender) {
        this.gender = gender;
        setGenderName();
    }

    public String getBornplace() {
        return bornplace;
    }

    public void setBornplace(String bornplace) {
        this.bornplace = bornplace;
    }

    public String getNativePlace() {
        return nativePlace;
    }

    public void setNativePlace(String nativePlace) {
        this.nativePlace = nativePlace;
    }

    public String getNation() {
        return nation;
    }

    public void setNation(String nation) {
        this.nation = nation;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getPolitical() {
        return political;
    }

    public void setPolitical(String political) {
        this.political = political;
    }

    public Integer getCertificateId() {
        return certificateId;
    }

    public void setCertificateId(Integer certificateId) {
        this.certificateId = certificateId;
    }

    public String getCettificateNum() {
        return cettificateNum;
    }

    public void setCettificateNum(String cettificateNum) {
        this.cettificateNum = cettificateNum;
        setAge();
    }

    public Date getCertificateTime() {
        return certificateTime;
    }

    public void setCertificateTime(Date certificateTime) {
        this.certificateTime = certificateTime;
    }

    public Integer getAge() {
        return age;
    }

    private void setAge() {
        //获取当前时间
        Date now = new Date();

        //获取生日的年
        int yearBirth = Integer.parseInt( cettificateNum.substring(6,10));
        //获取今天的年
        int yearNow = now.getYear()+1900;

        //获取月
        int monthBirth = Integer.parseInt( cettificateNum.substring(10,12));
        int monthNow = now.getMonth()+1;

        //获取日
        int dateBirth = Integer.parseInt( cettificateNum.substring(12,14));
        int dateNow = now.getDate();

        /* 计算年龄 */
        //基础年龄
        this.age = yearNow - yearBirth;

        //判断月份
        if (monthNow > monthBirth) return;

        if (monthNow < monthBirth) {
            this.age--;
            return;
        }

        //判断日
        if (dateNow >= dateBirth) return;
        this.age--;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getBloodtype() {
        return bloodtype;
    }

    public void setBloodtype(String bloodtype) {
        this.bloodtype = bloodtype;
    }

    public String getFatherName() {
        return fatherName;
    }

    public void setFatherName(String fatherName) {
        this.fatherName = fatherName;
    }

    public String getMotherName() {
        return motherName;
    }

    public void setMotherName(String motherName) {
        this.motherName = motherName;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmergentPhone() {
        return emergentPhone;
    }

    public void setEmergentPhone(String emergentPhone) {
        this.emergentPhone = emergentPhone;
    }

    public Integer getDormitoryId() {
        return dormitoryId;
    }

    public void setDormitoryId(Integer dormitoryId) {
        this.dormitoryId = dormitoryId;
    }

    public Integer getTeacherId() {
        return teacherId;
    }

    public void setTeacherId(Integer teacherId) {
        this.teacherId = teacherId;
    }

    public Integer getRoleId() {
        return roleId;
    }

    public void setRoleId(Integer roleId) {
        this.roleId = roleId;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getDreamSchool() {
        return dreamSchool;
    }

    public void setDreamSchool(String dreamSchool) {
        this.dreamSchool = dreamSchool;
    }

    public Integer getIsPre() {
        return isPre;
    }

    public void setIsPre(Integer isPre) {
        this.isPre = isPre;
        setIsPreName();
    }

    public Integer getIsOnly() {
        return isOnly;
    }

    public void setIsOnly(Integer isOnly) {
        this.isOnly = isOnly;
        setIsOnlyName();
    }

    public Integer getIsLeftOver() {
        return isLeftOver;
    }

    public void setIsLeftOver(Integer isLeftOver) {
        this.isLeftOver = isLeftOver;
        setIsLeftOverName();
    }

    public Integer getIsMigrant() {
        return isMigrant;
    }

    public void setIsMigrant(Integer isMigrant) {
        this.isMigrant = isMigrant;
        setIsMigrantName();
    }

    public Integer getIsMigrantWorker() {
        return isMigrantWorker;
    }

    public void setIsMigrantWorker(Integer isMigrantWorker) {
        this.isMigrantWorker = isMigrantWorker;
        setIsMigrantWorkerName();
    }

    public Integer getIsOrphan() {
        return isOrphan;
    }

    public void setIsOrphan(Integer isOrphan) {
        this.isOrphan = isOrphan;
        setIsOrphanName();
    }

    public Integer getIsSingleParent() {
        return isSingleParent;
    }

    public void setIsSingleParent(Integer isSingleParent) {
        this.isSingleParent = isSingleParent;
        setIsSingleParentName();
    }

    public Integer getIsMartyr() {
        return isMartyr;
    }

    public void setIsMartyr(Integer isMartyr) {
        this.isMartyr = isMartyr;
        setIsMartyrName();
    }

    public Integer getIsDisabled() {
        return isDisabled;
    }

    public void setIsDisabled(Integer isDisabled) {
        this.isDisabled = isDisabled;
        setIsDisabledName();
    }

    public Integer getIsAssinDegree() {
        return isAssinDegree;
    }

    public void setIsAssinDegree(Integer isAssinDegree) {
        this.isAssinDegree = isAssinDegree;
        setIsAssinDegreeName();
    }

    public Integer getIsSupport() {
        return isSupport;
    }

    public void setIsSupport(Integer isSupport) {
        this.isSupport = isSupport;
        setIsSupportName();
    }

    public Integer getIsSubsidy() {
        return isSubsidy;
    }

    public void setIsSubsidy(Integer isSubsidy) {
        this.isSubsidy = isSubsidy;
        setIsSubsidyName();
    }

    public Classes getClasses() {
        return classes;
    }

    public void setClasses(Classes classes) {
        this.classes = classes;
    }

    public String getGenderName() {
        return genderName;
    }

    private void setGenderName() {
        //判断, 赋值
        switch (gender){
            case 1:
                genderName = "男";
                break;
            case 2:
                genderName = "女";
                break;
            case 0:
                genderName = "保密";
                break;
        }
    }

    public Certificate getCertificate() {
        return certificate;
    }

    public void setCertificate(Certificate certificate) {
        this.certificate = certificate;
    }

    public Dormitory getDormitory() {
        return dormitory;
    }

    public void setDormitory(Dormitory dormitory) {
        this.dormitory = dormitory;
    }

    public Teachers getTeachers() {
        return teachers;
    }

    public void setTeachers(Teachers teachers) {
        this.teachers = teachers;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }


    public String getIsPreName() {
        return isPreName;
    }

    private void setIsPreName() {
        if (isPre==1){
            isPreName="是";
        }else {
            isPreName="否";
        }
    }

    public String getIsOnlyName() {
        return isOnlyName;
    }

    private void setIsOnlyName() {
        if (isOnly==1){
            isOnlyName="是";
        }else {
            isOnlyName="否";
        }
    }

    public String getIsLeftOverName() {
        return isLeftOverName;
    }

    private void setIsLeftOverName() {
        if (isLeftOver==1){
            isLeftOverName="是";
        }else {
            isLeftOverName="否";
        }
    }

    public String getIsMigrantName() {
        return isMigrantName;
    }

    private void setIsMigrantName() {
        if (isMigrant==1){
            isMigrantName="是";
        }else {
            isMigrantName="否";
        }
    }

    public String getIsMigrantWorkerName() {
        return isMigrantWorkerName;
    }

    private void setIsMigrantWorkerName() {
        if (isMigrantWorker==1){
            isMigrantWorkerName="是";
        }else {
            isMigrantWorkerName="否";
        }
    }

    public String getIsOrphanName() {
        return isOrphanName;
    }

    private void setIsOrphanName() {
        if (isOrphan==1){
            isOrphanName="是";
        }else {
            isOrphanName="否";
        }
    }

    public String getIsSingleParentName() {
        return isSingleParentName;
    }

    private void setIsSingleParentName() {
        if (isSingleParent==1){
            isSingleParentName="是";
        }else {
            isSingleParentName="否";
        }
    }

    public String getIsMartyrName() {
        return isMartyrName;
    }

    private void setIsMartyrName() {
        if (isMartyr==1){
            isMartyrName="是";
        }else {
            isMartyrName="否";
        }
    }

    public String getIsDisabledName() {
        return isDisabledName;
    }

    private void setIsDisabledName() {
        if (isDisabled==1){
            isDisabledName="是";
        }else {
            isDisabledName="否";
        }
    }

    public String getIsAssinDegreeName() {
        return isAssinDegreeName;
    }

    private void setIsAssinDegreeName() {
        if (isAssinDegree==1){
            isAssinDegreeName="是";
        }else {
            isAssinDegreeName="否";
        }
    }

    public String getIsSupportName() {
        return isSupportName;
    }

    private void setIsSupportName() {
        if (isSupport==1){
            isSupportName="是";
        }else {
            isSupportName="否";
        }
    }

    public String getIsSubsidyName() {
        return isSubsidyName;
    }

    private void setIsSubsidyName() {
        if (isSubsidy==1){
            isSubsidyName="是";
        }else {
            isSubsidyName="否";
        }
    }
}
